#include  <iostream>
using namespace std;

int find_max(int *arr, int *res, int n, int i)
{
	if( i == n-1 )
	{
		return res[i] = arr[i];
	}

	int max_next = find_max(arr,res,n,i+1);
	res[i] = max_next > 0 ? arr[i] + res[i+1] : arr[i];
	
	return res[i];
}

int main(int argc, char *argv[])
{
	int a[] = {5,-3,10,-5,-6,3,-1,-11,4,-2,3};
	int b[11];
	find_max(a,b,11,0);

	int max = b[0];
	for( int i = 0 ; i < 11 ; ++i )
	{
		if(b[i] > max)
			max = b[i];
	}
	
	cout << max << endl;
}
